package com.cssy.xxkj.logic.dao.impl;

import com.cssy.xxkj.logic.dao.LogicProductionStorageoutDAO;
import com.cssy.xxkj.logic.entity.LogicProductionStorageoutDO;
import com.cssy.xxkj.logic.entity.vo.LogicSalesDetailVO;
import com.plat.helper.SearchConditions;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2014-10-09
 */
public class LogicProductionStorageoutDAOImpl extends SqlMapClientDaoSupport implements LogicProductionStorageoutDAO {

    /**
     * 插入数据
     * @param logicProductionStorageoutDO
     * @return 插入数据的主键
     */
    public String insertLogicProductionStorageoutDO(LogicProductionStorageoutDO logicProductionStorageoutDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicProductionStorageout.insert", logicProductionStorageoutDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProductionStorageoutDO
     * @return 查出的记录数
     */
    public Integer countLogicProductionStorageoutDOByExample(LogicProductionStorageoutDO logicProductionStorageoutDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionStorageout.countByDOExample", logicProductionStorageoutDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProductionStorageoutDO
     * @return 受影响的行数
     */
    public Integer updateLogicProductionStorageoutDO(LogicProductionStorageoutDO logicProductionStorageoutDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicProductionStorageout.update", logicProductionStorageoutDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProductionStorageoutDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProductionStorageoutDO> findListByExample(LogicProductionStorageoutDO logicProductionStorageoutDO) throws DataAccessException {
        List<LogicProductionStorageoutDO> list = getSqlMapClientTemplate().queryForList("LogicProductionStorageout.findListByDO", logicProductionStorageoutDO);
        return list;
    }

    /**
     * 根据主键获取logicProductionStorageoutDO
     * @param id
     * @return logicProductionStorageoutDO
     */
    public LogicProductionStorageoutDO findLogicProductionStorageoutDOByPrimaryKey(String id) throws DataAccessException {
        LogicProductionStorageoutDO logicProductionStorageoutDO = (LogicProductionStorageoutDO) getSqlMapClientTemplate().queryForObject("LogicProductionStorageout.findByPrimaryKey", id);
        return logicProductionStorageoutDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProductionStorageoutDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProductionStorageout.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProductionStorageoutDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProductionStorageoutDO> list = getSqlMapClientTemplate().queryForList("LogicProductionStorageout_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionStorageout_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProductionStorageout_ex.deleteBizRemoved", id);
        return rows;
	}
	
	@Override
	public List<LogicSalesDetailVO> findQuerySaleDetailByScs(SearchConditions scs){
		List<LogicSalesDetailVO> detailListVo = getSqlMapClientTemplate().queryForList("LogicProductionStorageout_ex.findQuerySaleDetailByScs", scs);
		return detailListVo;
	}
	
	@Override
	public Integer countQuerySaleDetailByScs(SearchConditions scs){
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionStorageout_ex.countQuerySaleDetailByScs", scs);
        return count;
	}

}